package com.ztx.service.base.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Service;

import com.ztx.service.base.IBaseService;

@Service("baseService")
public class BaseServiceImpl implements IBaseService {

	@Resource
	private SqlSessionTemplate sqlSessionTemplate = null;

	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public int add(String sqlId, Object args) throws Exception {
		return sqlSessionTemplate.insert(sqlId, args);
	}

	@Override
	public int add(String sqlId) throws Exception {
		return sqlSessionTemplate.insert(sqlId);
	}

	@Override
	public int delete(String sqlId, Object args) throws Exception {
		return sqlSessionTemplate.delete(sqlId, args);
	}

	@Override
	public int delete(String sqlId) throws Exception {
		return sqlSessionTemplate.delete(sqlId);
	}

	@Override
	public int update(String sqlId, Object args) throws Exception {
		return sqlSessionTemplate.update(sqlId, args);
	}

	@Override
	public int update(String sqlId) throws Exception {
		return sqlSessionTemplate.update(sqlId);
	}

	@Override
	public <T> T selectOne(String sqlId) throws Exception {
		return sqlSessionTemplate.selectOne(sqlId);
	}

	@Override
	public <T> T selectOne(String sqlId, Object param) throws Exception {
		return sqlSessionTemplate.selectOne(sqlId, param);
	}

	@Override
	public <E> List<E> selectList(String sqlId) throws Exception {
		return sqlSessionTemplate.selectList(sqlId);
	}

	@Override
	public <E> List<E> selectList(String sqlId, Object parameter)
			throws Exception {
		return sqlSessionTemplate.selectList(sqlId, parameter);
	}

	@Override
	public <E> List<E> selectList(String sqlId, Object parameter,
			RowBounds rowBounds) {
		return sqlSessionTemplate.selectList(sqlId, parameter, rowBounds);
	}
}
